// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Axios from 'axios'


if (process.env.NODE_ENV == "development") {
  Axios.defaults.baseURL = 'http://127.0.0.1:5000';
}
else {
  Axios.defaults.baseURL = 'http://gansu-server.sydwzk.cn/api';
}


//请求前
Axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么

  return config
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error)
});

//请求后
Axios.interceptors.response.use(
  response => {

    return response.data;

  }, error => {

    if (error.response) {

      switch (error.response.status) {

        case 403:

          break;
      }

    }
    return Promise.reject({ status: error.response.status, message: error.response.data })
  }
);


Vue.prototype.$axios = Axios;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
